function a(a, t, e) {
    return t in a ? Object.defineProperty(a, t, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : a[t] = e, a;
}

for (var t = require("../../utils/api.js"), e = getApp(), o = new Date(), n = [], s = [], d = [], i = 1990; i <= o.getFullYear(); i++) n.push(i);

for (var l = 1; l <= 12; l++) l < 10 ? s.push("0" + l) : s.push(l);

for (var r = 1; r <= 31; r++) r < 10 ? d.push("0" + r) : d.push(r);

Page({
    data: {
        nav: [ {
            name: "全部",
            color: "#ff5555",
            on: !0,
            type: "all"
        }, {
            name: "最近7天",
            color: "#ff5555",
            on: !1,
            type: "seven"
        }, {
            name: "最近30天",
            color: "#ff5555",
            on: !1,
            type: "thirty"
        }, {
            name: "上月记录",
            color: "#ff5555",
            on: !1,
            type: "lastmonth"
        } ],
        years: n,
        year: o.getFullYear(),
        months: s,
        month: o.getMonth() + 1,
        days: d,
        day: o.getDate(),
        value: [ 9999, o.getMonth(), o.getDate() ],
        showLoding: !1
    },
    onLoad: function(a) {},
    onShow: function() {
        var a = this;
        console.log(o.getMonth(), o.getDate()), t.GetHeadSendOrderList({
            openid: e.globalData.openid
        }).then(function(t) {
            if (console.log(t), 0 == t.errno) {
                var e = t.data.data;
                if (t.data.data && t.data.data.length < 10) o = ""; else var o = 2;
                for (var n = 0; n < e.length; n++) e[n].all_num == e[n].get_send_num ? e[n].has_get = !0 : e[n].has_get = !1;
                a.setData({
                    info: e,
                    page: o
                });
            } else a.setData({
                showNo: !0
            });
            a.setData({
                showLoding: !0
            });
        });
    },
    changenav: function(o) {
        console.log(o);
        var n = this, s = o.currentTarget.dataset.type;
        n.setData({
            showNo: !1,
            showLoding: !1
        });
        for (var d = 0; d < n.data.nav.length; d++) {
            var i = "nav[" + d + "].on";
            if (n.data.nav[d].type == s) {
                var l;
                n.setData((l = {}, a(l, i, !0), a(l, "type", s), a(l, "noMore", !1), l));
            } else n.setData(a({}, i, !1));
        }
        if ("all" == s) return t.GetHeadSendOrderList({
            openid: e.globalData.openid
        }).then(function(a) {
            console.log(a);
            var t = a.data.data;
            if (0 == a.errno) {
                if (a.data.data && a.data.data.length < 10) e = ""; else var e = 2;
                for (var o = 0; o < t.length; o++) t[o].all_num == t[o].get_send_num ? t[o].has_get = !0 : t[o].has_get = !1;
                n.setData({
                    info: t,
                    page: e
                });
            } else n.setData({
                showNo: !0,
                info: []
            });
            n.setData({
                showLoding: !0
            });
        }), !1;
        if ("seven" == s) s = 1;
        if ("thirty" == s) s = 2;
        if ("lastmonth" == s) s = 3;
        t.GetHeadSendOrderList({
            openid: e.globalData.openid,
            type: s
        }).then(function(a) {
            console.log(a);
            var t = a.data.data;
            if (0 == a.errno) {
                if (a.data.data && a.data.data.length < 10) e = ""; else var e = 2;
                for (var o = 0; o < t.length; o++) t[o].all_num == t[o].get_send_num ? t[o].has_get = !0 : t[o].has_get = !1;
                n.setData({
                    info: t,
                    page: e
                });
            } else n.setData({
                showNo: !0,
                info: []
            });
            n.setData({
                showLoding: !0
            });
        });
    },
    bindChange: function(a) {
        var t = a.detail.value;
        this.setData({
            year: this.data.years[t[0]],
            month: this.data.months[t[1]],
            day: this.data.days[t[2]],
            setvalue: [ t[0], t[1], t[2] ]
        }), console.log(this.data.year, this.data.month, this.data.day);
    },
    selectdata: function() {
        this.setData({
            selectData: !0
        });
    },
    datecomfirm: function() {
        var a = this, o = a.data.year + "-" + a.data.month + "-" + a.data.day;
        console.log(o), a.setData({
            showLoding: !1
        }), t.GetHeadSendOrderList({
            openid: e.globalData.openid,
            days: o
        }).then(function(t) {
            if (console.log(t), 0 == t.errno) {
                for (var e = t.data.data, o = 0; o < e.length; o++) e[o].all_num == e[o].get_send_num ? e[o].has_get = !0 : e[o].has_get = !1;
                a.setData({
                    info: t.data.data,
                    showNo: !1
                });
            } else a.setData({
                showNo: !0,
                info: []
            });
            a.setData({
                showLoding: !0
            });
        }), a.setData({
            selectData: !1,
            value: a.data.setvalue
        });
    },
    cancel: function() {
        this.setData({
            selectData: !1
        });
    },
    comfirm: function(o) {
        var n = this, s = o.currentTarget.dataset.lid;
        console.log(s), t.HeadSureSendOrderList({
            openid: e.globalData.openid,
            lid: s
        }).then(function(t) {
            if (console.log(t), 1 == t.errno) wx.showToast({
                title: "还有未发货商品，无法确认收货",
                duration: 2e3,
                icon: "none"
            }); else {
                wx.showToast({
                    title: t.message,
                    duration: 2e3,
                    icon: "none"
                });
                for (var e = 0; e < n.data.info.length; e++) if (s == n.data.info[e].lid) {
                    var o = "info[" + e + "].has_get";
                    n.setData(a({}, o, !0));
                }
                n.onLoad();
            }
        });
    },
    onReachBottom: function() {
        var a = this, o = a.data.page, n = a.data.info;
        o && t.GetHeadSendOrderList({
            openid: e.globalData.openid,
            page: o
        }).then(function(t) {
            if (console.log(t), 0 == t.errno) {
                for (var e = 0; e < t.data.data.length; e++) n.push(t.data.data[e]);
                if (t.data.data.length < 10) ; else ;
                a.setData({
                    info: n
                });
            }
        });
    }
});